package com.android.car.recoverydemo;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class MainActivity extends Activity {

    private final static String TAG = "RecoveryDemo";

    private boolean mEraseSdCard = true;
    private boolean mEraseEsims = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    private void doMasterClear() {
        Intent intent = new Intent(Intent.ACTION_FACTORY_RESET);
        intent.setPackage("android");
        intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        intent.putExtra(Intent.EXTRA_REASON, "MasterClearConfirm");
        intent.putExtra(Intent.EXTRA_WIPE_EXTERNAL_STORAGE, mEraseSdCard);
        intent.putExtra(Intent.EXTRA_WIPE_ESIMS, mEraseEsims);
        sendBroadcast(intent);
        // Intent handling is asynchronous -- assume it will happen soon.
    }

    public void doFactoryReset(View view) {
        Log.d(TAG, "doFactoryReset ... ");

        doMasterClear();
    }

    public void doOTA(View view) {
        Log.d(TAG, "doFactoryReset ... ");
    }
}
